﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>和我聊天吧</title>
</head>
<body class="easyui-layout">
   
    <link href="../hcjsui/jquery-easyui-1.3.3/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../hcjsui/jquery-easyui-1.3.3/themes/icon.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" rev="stylesheet" type="text/css" href="../hcjsui/Styles/usbocx.css" />
    <style type="text/css">
        body
        {
            margin-left: 0px;
            margin-top: 0px;
            margin-right: 0px;
            margin-bottom: 0px;
            background-color: #EEF2FB;
        }

        .gridRow
        {
            width: 500px;
        }
    </style>
    <script src="../hcjsui/Scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script src="../hcjsui/jquery-easyui-1.3.3/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../hcjsui/jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js" charset="utf-8" type="text/javascript"></script>
    <script src="../hcjsui/Scripts/jquery.form.js" type="text/javascript"></script>
    <script src="../hcjsui/js/json2.js" type="text/javascript"></script>
    <script src="../hcjsui/js/_Define.js" type="text/javascript"></script>
    <script src="../hcjsui/js/customer.js" type="text/javascript"></script>
    <script type="text/javascript" src="../hcjsui/js/usbocx.js"></script>
    <script src="../hcjsui/Scripts/jquery.validate.js" type="text/javascript"></script>
    <script src="../hcjsui/js/easyui-extend/form.js" type="text/javascript"></script>
    <script src="../hcjsui/js/easyui-extend/window.js" type="text/javascript"></script>
    <script src="../hcjsui/js/validateExtends.js" type="text/javascript"></script>
    <script type="text/javascript" src="../js/hc.js"></script>
    <div id="ui_department_layout" class="easyui-layout" data-options="fit:true,border:false">
        <div region="north" title="和我聊天吧！" split="false" border="false" style="height: 60px;">
          
        </div>
        <div region="center"  id="divlistinfo" title="信息列表" style="padding: 0px;" border="false">

            

        </div>
      <div region="south" border="true" split="true" style="overflow: hidden; height: 40px;">
          <input id="Text1" type="text" /><input id="Button1" type="button" value="发送" onclick="addinfo()" />
    </div>
    </div>

    <script type="text/javascript">
        jQuery.support.cors = true;
        function addinfo()
        {
            var divshow = $("#divlistinfo");
           // divshow.text("");// 清空数据
            divshow.append("我说：" + $("#Text1").val() + "<br/>"); // 添加Html内容，不能用Text 或 Val
            //方法1

            $.get("http://www.tuling123.com/openapi/api?key=a7ccfc620ea11e261c783aede82dcac8&info=" + EncodeUtf8( $("#Text1").val()),
                     function (data) {
                         callbackc( data.text)
                     });
            //方法1 winform 
           // callForm("talkinfo", "1", $("#Text1").val(), "callbackc");
        }
        function callbackc( i)
        {
          
            var divshow = $("#divlistinfo");
            // divshow.text("");// 清空数据
            divshow.append("**MM说：" + i + "<br/>"); // 添加Html内容，不能用Text 或 V
        }
        function EncodeUtf8(s1) {
            var s = escape(s1);
            var sa = s.split("%");
            var retV = "";
            if (sa[0] != "") {
                retV = sa[0];
            }
            for (var i = 1; i < sa.length; i++) {
                if (sa[i].substring(0, 1) == "u") {
                    retV += Hex2Utf8(Str2Hex(sa[i].substring(1, 5)));

                }
                else retV += "%" + sa[i];
            }

            return retV;
        }
        function Str2Hex(s) {
            var c = "";
            var n;
            var ss = "0123456789ABCDEF";
            var digS = "";
            for (var i = 0; i < s.length; i++) {
                c = s.charAt(i);
                n = ss.indexOf(c);
                digS += Dec2Dig(eval(n));

            }
            //return value;
            return digS;
        }
        function Dec2Dig(n1) {
            var s = "";
            var n2 = 0;
            for (var i = 0; i < 4; i++) {
                n2 = Math.pow(2, 3 - i);
                if (n1 >= n2) {
                    s += '1';
                    n1 = n1 - n2;
                }
                else
                    s += '0';

            }
            return s;

        }
        function Dig2Dec(s) {
            var retV = 0;
            if (s.length == 4) {
                for (var i = 0; i < 4; i++) {
                    retV += eval(s.charAt(i)) * Math.pow(2, 3 - i);
                }
                return retV;
            }
            return -1;
        }
        function Hex2Utf8(s) {
            var retS = "";
            var tempS = "";
            var ss = "";
            if (s.length == 16) {
                tempS = "1110" + s.substring(0, 4);
                tempS += "10" + s.substring(4, 10);
                tempS += "10" + s.substring(10, 16);
                var sss = "0123456789ABCDEF";
                for (var i = 0; i < 3; i++) {
                    retS += "%";
                    ss = tempS.substring(i * 8, (eval(i) + 1) * 8);



                    retS += sss.charAt(Dig2Dec(ss.substring(0, 4)));
                    retS += sss.charAt(Dig2Dec(ss.substring(4, 8)));
                }
                return retS;
            }
            return "";
        }


    </script>
</body>
</html>
